/**
 * <p>Title: SpringConfigTool</p>
 * <p>Description: 提供 Sprint 上下文支持</p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author Zuo Yefeng
 * @version 1.0
 * <pre>Histroy:
 *       2016-9-27  Zuo Yefeng  Create
 *</pre>
*/

package cn.jhg.account.util;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class SpringConfigTool implements ApplicationContextAware{
	private static ApplicationContext context = null;
	private static SpringConfigTool stools = null;

	public synchronized static SpringConfigTool init() {
		if (stools == null) {
			stools = new SpringConfigTool();
		}
		return stools;
	}

	@Override
	public void setApplicationContext(ApplicationContext applicationContext)
			throws BeansException {
		context = applicationContext;
	}
	
	/**
	 * 获取 Bean 方法
	 * @param beanName
	 * @return
	 */
	public synchronized static Object getBean(String beanName) {
		return context.getBean(beanName);
	}

	public static boolean isInit(){
		return context != null;
	}
}
